import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

import * as path from "path"

// https://vitejs.dev/config/
export default defineConfig({
  resolve: {
    alias: { // 设置别名
      "@": path.resolve(__dirname, "src"),
    },
  },
  plugins: [vue()],
  server: {
    cors: true, // 默认启用并允许任何源
    host: '0.0.0.0',
    port: 8888,
    proxy: {
      '/healthcenter/api': {
        target: 'http://127.0.0.1:8011',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/healthcenter\/api/, '/healthcenter/api')
      },
    }
  },
  build: {
    // 打包输出目录
    outDir: 'dist',
    // 通过 filehash 生成哈希值的文件名
    assetsInlineLimit: 0,  // 保证所有的静态资源都生成文件名 hash
    // 打包文件大小警告阈值
    chunkSizeWarningLimit: 1000
  }
})
